<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/14
 * Time: 17:39
 */
namespace App\Http\Controllers\Api\V1_9_1;

use App\Http\Requests\Api\V1_9_1\RepaymentAccountWithdrawRequest;
use App\Services\RepaymentAccountWithdrawService;
use Illuminate\Http\Request;

class RepaymentAccountWithdrawController extends BaseController
{
    protected $repaymentAccountWithdrawService;

    public function __construct(RepaymentAccountWithdrawService $repaymentAccountWithdrawService)
    {
        parent::__construct();
        $this->repaymentAccountWithdrawService = $repaymentAccountWithdrawService;
    }

    /**
     * 账户余额
     */
    public function accountBalance()
    {
        return $this->repaymentAccountWithdrawService->accountBalance($this->user['user_id']);
    }

    /**
     * 提现
     */
    public function withdraw(RepaymentAccountWithdrawRequest $request)
    {
        $passageId = 1;
        return $this->repaymentAccountWithdrawService->withdraw($request, $this->user['user_id'], $passageId);
    }

    /**
     * 交易明细
     */
    public function tradeDetail(Request $request)
    {
        if (isset($request->status) && !empty($request->status)) {
            $status = $request->status;
        } else {
            $status = 0;
        }
        return $this->repaymentAccountWithdrawService->tradeDetail($this->user['user_id'], $status, $request->page);
    }
}